package com.erbantou.filemanage.entity.multipart;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

public class DecodedMultipartFile implements MultipartFile {

    private final MultipartFile original;
    private final String decodedFilename;

    public DecodedMultipartFile(MultipartFile original, String decodedFilename) {
        this.original = original;
        this.decodedFilename = decodedFilename;
    }

    @Override
    public String getName() {
        return original.getName();
    }

    @Override
    public String getOriginalFilename() {
        return decodedFilename;
    }

    @Override
    public String getContentType() {
        return original.getContentType();
    }

    @Override
    public boolean isEmpty() {
        return original.isEmpty();
    }

    @Override
    public long getSize() {
        return original.getSize();
    }

    @Override
    public byte[] getBytes() throws IOException {
        return original.getBytes();
    }

    @Override
    public InputStream getInputStream() throws IOException {
        return original.getInputStream();
    }

    @Override
    public void transferTo(File dest) throws IOException, IllegalStateException {
        original.transferTo(dest);
    }
}
